<?php

namespace App\Http\Controllers\API\Admin;

use App\Http\Controllers\Controller;
use App\Miya\Models\Classify;
use Illuminate\Http\Request;

class DebrisController extends Controller
{
    public function getClassifies()
    {
        $classifies = Classify::selectOptions(function ($query) {
            return $query->where('module_id', request()->get('q'));
        });

        $data = [];
        collect($classifies)->each(function ($classify, $key) use (&$data) {
            if ($key == 0) {
                return;
            }
            $classify = str_replace('&nbsp;', '·', $classify);
            $data[] = ['id' => $key, 'text' => $classify];
        });

        return $data;
    }
}
